package com.huixiaodian.baselibrary.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class ToastUtil {

    /**
     * @param context 上下文信息
     * @param string  显示的文本信息
     */
    public static void toast_short(Context context, String string) {
        Toast.makeText(context, string, Toast.LENGTH_SHORT).show();
    }

    /**
     * @param context 上下文信息
     * @param resId   显示文本信息的资源ID
     */
    public static void toast_long(Context context, int resId) {
        Toast.makeText(context, resId, Toast.LENGTH_LONG).show();
    }

    /**
     * @param context 上下文信息
     * @param string  显示的文本信息
     */
    public static void toast_long(Context context, String string) {
        Toast.makeText(context, string, Toast.LENGTH_LONG).show();
    }

//    public static void toastCommonCustomView(Context context, String string) {
//        View contentView = View.inflate(context, R.layout.layout_toast, null);
//        TextView textView = contentView.findViewById(R.id.tv_name);
//        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
//                UIUtil.dipToPx(context, 150), UIUtil.dipToPx(context, 40));
//        textView.setLayoutParams(params);
//        textView.setText(string);
//        Toast mToast = new Toast(context);
//        mToast.setView(contentView);
//        mToast.setDuration(Toast.LENGTH_LONG);
//        mToast.setGravity(Gravity.CENTER, 0, 0);
//        mToast.show();
//    }
//
//    public static void toastCommonCustomView2(Context context, int resId){
//        View contentView = View.inflate(context, R.layout.layout_toast, null);
//        TextView textView = contentView.findViewById(R.id.tv_name);
//        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
//                UIUtil.dipToPx(context, 200), UIUtil.dipToPx(context, 80));
//        textView.setLayoutParams(params);
//        textView.setText(resId);
//        Toast mToast = new Toast(context);
//        mToast.setGravity(Gravity.CENTER_HORIZONTAL, 0,
//                UIUtil.dipToPx(context, 200));
//        mToast.setDuration(Toast.LENGTH_LONG);
//        mToast.setView(contentView);
//        mToast.show();
//    }
//
//    public static void toastCommonCustomView2(Context context, String string){
//        View contentView = View.inflate(context, R.layout.layout_toast, null);
//        TextView textView = contentView.findViewById(R.id.tv_name);
//        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
//                UIUtil.dipToPx(context, 200), UIUtil.dipToPx(context, 80));
//        textView.setLayoutParams(params);
//        textView.setText(string);
//        Toast mToast = new Toast(context);
//        mToast.setGravity(Gravity.CENTER_HORIZONTAL, 0,
//                UIUtil.dipToPx(context, 200));
//        mToast.setDuration(Toast.LENGTH_LONG);
//        mToast.setView(contentView);
//        mToast.show();
//    }
}
